package beautiful.butterfly.schedule.test;

import beautiful.butterfly.schedule.strategy.IStrategyTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JavaStrategyTaskDemo implements IStrategyTask, Runnable {
    protected static transient Logger log = LoggerFactory.getLogger(JavaStrategyTaskDemo.class);


    private String parameter;
    private volatile boolean isStop = false;//以后实现统一停止标识

    public void init(String strategyName, String parameter) {
        this.parameter = parameter;
        new Thread(this).start();
    }

    @Override
    public void stop(String strategyName) throws Exception {
        this.isStop = true;
    }

    @Override
    public void run() {
        while (!isStop) {
            log.error(this.parameter);
            if (isStop) {
                System.out.println("break");
                //throw new RuntimeException("stop!!!");
                break;
            }
        }
    }

}
